package ru.msu.phys.cmp.mpga.domain.bresenham;


import ru.msu.phys.cmp.mpga.domain.Point;

public class BresenhamLine extends BresenhamObject{
	
	
	public BresenhamLine( int x1, int y1, int x2, int y2) {
		
   	    double m = ((double)y2 - (double)y1) / ((double)x2 - (double)x1);
   		double F = 0;
   		int x = x1;
   		int y = y1;
   		
   		points.add(new Point(x,y));
   		
   		while (x < x2) {
   			x++;
   			F += m;
   			if (F > 0.5) {
   				y++;
   				F--;
   			}
   			points.add(new Point(x,y));
   		}
	}
}
